<extend name="template/base"/>
<block name="area_header">

</block>

<block name="area_body">
    <div class="col-lg-10 col-md-10 col-lg-offset-1 col-md-offset-1 clearfix">
        <h2>Token获取测试 GET 请求</h2>
        <form class="form-horizontal authForm" action="{:U('Api/Authorize/index')}" method="get">

            <div class="form-group">
                <label class="control-label col-lg-2 col-md-2">RESPONSE TYPE</label>

                <div class="col-lg-10 col-md-10">
                    <input type="text" name="response_type" class="form-control" value="token"/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-lg-2 col-md-2">ClientID</label>
                <div class="col-lg-10 col-md-10">
                    <input type="text" name="client_id" class="form-control" value="by559a8de1c325c1"/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-lg-2 col-md-2">redirect_uri</label>
                <div class="col-lg-10 col-md-10">
                    <input type="text" name="redirect_uri" class="form-control"  value="http://localhost/github/201507lanbao/index.php/Test/OAuth2/auth_code"/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-lg-2 col-md-2">state</label>
                <div class="col-lg-10 col-md-10">
                    <input type="text" name="state" class="form-control"  value="state_random"/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-lg-2 col-md-2">&nbsp;</label>

                <div class="col-lg-10 col-md-10">
                    <button type="submit" class="btn btn-sm btn-primary "  >提交</button>
                </div>
            </div>
        </form>

        <div class="well js_panel">

        </div>
    </div>
</block>

<block name="area_footer">
    <script type="text/javascript">
        $(function(){
            $(".js_submit").click(function(ev){
                var that = ev.target;
                $(that).button("loading");
                var form = $(".authForm");
                var query = form.serialize();
                var target = "{:U('Api/Authorize/index')}";
                $.get(target, query).always(function() {
                    setTimeout(function(){
                        $(that).button("reset");
                    },1400);
                }).done(function(data) {
                    console.log(data);
                }).fail(function(data){
                    var json = JSON.parseJSON(data.responseText);
                    console.log(json);
                });//end post

            })
        });
    </script>
</block>
